//
//  EditToolBarVIew.m
//  WeCommunity
//
//  Created by mac on 2017/6/16.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "EditToolBarVIew.h"

@implementation EditToolBarVIew

-(instancetype)initWithFrame:(CGRect)frame  uiType:(NSInteger)type
{
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = WHITE_COLOR;
        
        NSArray * imageArray = @[@"photo",@"camera"];
        for (int i = 0; i < imageArray.count ; i++) {
            UIButton * chooseButton = [[UIButton alloc] initWithFrame:CGRectMake(30 + (30 + 30) * i, CGRectGetMidY(self.bounds) - 15, 30, 30)];
            [chooseButton setImage:[UIImage imageNamed:imageArray[i]] forState:UIControlStateNormal];
            chooseButton.tag = 10 + i;
            [chooseButton addTarget:self action:@selector(processChooseBtn:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:chooseButton];
        }
        
        if (type == 1) {
            UIButton * chooseButton = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetWidth(self.bounds) - 64, CGRectGetMidY(self.bounds) - 16, 32, 32)];
            [chooseButton setImage:[UIImage imageNamed:@"addLinkUrl"] forState:UIControlStateNormal];
            chooseButton.tag = 12;
            [chooseButton addTarget:self action:@selector(processChooseBtn:) forControlEvents:UIControlEventTouchUpInside];
            [self addSubview:chooseButton];
        }
        
        UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0,0, CGRectGetWidth(self.bounds), 0.5)];
        lineView.backgroundColor = LINE_COLOR;
        [self addSubview:lineView ];
        
    }
    return self;
}

-(void)processChooseBtn:(UIButton *)sender
{
    if (self.delegate) {
        [self.delegate editToolBarSeletedIndex:sender.tag - 10];
    }
    
}

@end
